//
//  WBBaseNaviController.swift
//  Weibo
//
//  Created by Apple on 16/11/12.
//  Copyright © 2016年 Wbw. All rights reserved.
//

import UIKit

class WBBaseNaviController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

//    重写push方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        let count = childViewControllers.count
        
        if count > 0 {
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(back))
            //隐藏底部的tabbar
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func back() {
        popViewController(animated: true)
    }
}
